package com.atguigu.bigdata.scala.chapter06;

public class Scala08_Object_Method_Java {
    public static void main(String[] args) {

        Emp emp1 = new Emp();
        emp1.id = 1001;
        Emp emp2 = new Emp();
        emp2.id = 1001;

        System.out.println(emp1.equals(emp2));
    }
}

class Emp {
    public int id;
    @Override
    public boolean equals(Object o) {
        // 比较的前提条件，应该类型相同
        if ( o instanceof Emp) {
            Emp other = (Emp)o;
            return this.id == other.id;
        } else {
            return false;
        }
    }
}
